﻿using BaoShouTangServer.DTOModel;
using BaoShouTangServer.Models;
using BaoShouTangServer.Service;
using MSXML2;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using UFIDA.U8.U8APIFramework;
using UFIDA.U8.U8MOMAPIFramework;

namespace BaoShouTangServer.ApiServies
{
    public class SO_SOMainService
    {

        public static string 生成销售订单(string sugarConfigId, U8Login.clsLogin u8Login, DtoSOMain dtoSOMain, ref string dlid, ref string 材料出库单接口返回result)
        {
            //第二步：构造环境上下文对象，传入login，并按需设置其它上下文参数
            U8EnvContext envContext = new U8EnvContext();
            envContext.U8Login = u8Login;

            //设置上下文参数
            envContext.SetApiContext("VoucherType", "12"); //上下文数据类型：int，含义：单据类型：12 网上找到，官方文档没写




            //第三步：设置API地址标识(Url)
            //当前API：添加新单据的地址标识为：U8API/MaterialOut/Add
            U8ApiAddress myApiAddress = new U8ApiAddress("U8API/SA/SAVoucher_Save");  


            //第四步：构造APIBroker
            U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);

            //第五步：API参数赋值

            //给普通参数sVouchType赋值。此参数的数据类型为System.String，此参数按值传递，表示单据类型：11
            //broker.AssignNormalValue("sVouchType", "9");



            //给BO表头参数DomHead赋值，此BO参数的业务类型为材料出库单，属表头参数。BO参数均按引用传递
            //提示：给BO表头参数DomHead赋值有两种方法

            DataTable Dt_data = new DataTable();

            DbHelperSQL.connectionString = u8Login.UFDataConnstringForNet;
            StringBuilder strMsg = new StringBuilder();
            StringBuilder Strsql = new StringBuilder();

            //创建临时表
            string StrHeadName = "SaleOrderQ" + Guid.NewGuid().ToString().Replace("-", "");
            string StrBodyName = "SaleOrderSQ" + Guid.NewGuid().ToString().Replace("-", "");
            Strsql.Append(" select  top 0  * into " + StrHeadName + " from SaleOrderQ Where 1=1");
            Strsql.Append(" \n select  top 0  *  into " + StrBodyName + " from SaleOrderSQ Where 1=1");
            DbHelperSQL.ExecuteSql(Strsql.ToString());
            int id = (int)SnowFlakeSingle.Instance.NextId();
            int zpurRkdHead = 销售订单头赋值(sugarConfigId,StrHeadName, id, dtoSOMain);
            int zpurRkdTailList = 销售订单体赋值(sugarConfigId,StrBodyName, id, dtoSOMain);
            //塞入临时表

            Strsql = new StringBuilder();
            Strsql.Append("select editprop='A',* from " + StrHeadName);
            DOMDocument domHead = Pub.getDom(Strsql.ToString(), u8Login.UfDbName);
            Strsql = new StringBuilder();
            Strsql.Append("select editprop='A',* from " + StrBodyName);
            DOMDocument domBody = Pub.getDom(Strsql.ToString(), u8Login.UfDbName);

            Strsql = new StringBuilder();
            Strsql.Append(" if not object_id('" + StrHeadName + "') is null drop table " + StrHeadName);
            Strsql.Append(" if not object_id('" + StrBodyName + "') is null drop table " + StrBodyName);

            DbHelperSQL.ExecuteSql(Strsql.ToString());

            broker.AssignNormalValue("DomHead", domHead);
            //方法一是直接传入MSXML2.DOMDocumentClass对象
            broker.AssignNormalValue("domBody", domBody);


            //给普通参数VoucherState赋值。此参数的数据类型为int，此参数按值传递，表示状态:0增加;1修改
            broker.AssignNormalValue("VoucherState", 0);


            //该参数VouchId为INOUT型普通参数。此参数的数据类型为System.String，此参数按值传递。在API调用返回时，可以通过GetResult("VouchId")获取其值
            string VouchId = "";
            broker.AssignNormalValue("vNewID", VouchId);


            //第六步：调用API
            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        材料出库单接口返回result = ("系统异常：" + sysEx.Message);
                        //todo:异常处理
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        材料出库单接口返回result = ("API异常：" + bizEx.Message);
                        //todo:异常处理
                    }
                    //异常原因
                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        材料出库单接口返回result = ("异常原因：" + exReason);
                    }
                }
                //结束本次调用，释放API资源
                broker.Release();
            }

            //第七步：获取返回结果

            //获取返回值
            //获取普通返回值。此返回值数据类型为System.String，此参数按值传递，表示错误描述：空，正确；非空，错误
            //System.String result = broker.GetReturnValue() as System.String;
            //材料出库单接口返回result = result;
            //获取普通OUT参数curID。此返回值数据类型为string，在使用该参数之前，请判断是否为空
            //string curIDRet = broker.GetResult("curID") as string;
            //获取普通OUT参数CurDom。此返回值数据类型为MSXML2.IXMLDOMDocument2，在使用该参数之前，请判断是否为空
            //MSXML2.IXMLDOMDocument2 CurDomRet = Convert.ToObject(broker.GetResult("CurDom"));
            //到货单接口返回result += JsonConvert.SerializeObject(broker.GetResult("CurDom"));


            //获取返回值
            //获取普通返回值。此返回值数据类型为System.String，此参数按值传递，表示成功返回空串
            string result = broker.GetReturnValue() as System.String;


            //获取普通INOUT参数VouchId。此返回值数据类型为System.String，在使用该参数之前，请判断是否为空
            System.String VouchIdRet = broker.GetResult("vNewID") as string;
            dlid = VouchIdRet;
            //获取普通OUT参数domMsg。此返回值数据类型为MSXML2.IXMLDOMDocument2，在使用该参数之前，请判断是否为空
            //MSXML2.IXMLDOMDocument2 domMsgRet = Convert.ToObject(broker.GetResult("domMsg"));

            //材料出库单接口返回result += JsonConvert.SerializeObject(broker.GetResult("domMsg"));
            //结束本次调用，释放API资源
            broker.Release();
            return result;

        }

        private static int 销售订单头赋值(string sugarConfigId, string strHeadName, int id, DtoSOMain dtoSOMain)
        {
            SaleOrderQ saleOrderQ = new SaleOrderQ();
            //saleOrderQ.ivouchstate = "Approved";
            saleOrderQ.csysbarcode = "||SA17|2025060500000200";
            //saleOrderQ.ccrmpersoncode = "NULL";
            //saleOrderQ.ccrmpersonname = "NULL";
            //saleOrderQ.cmainpersoncode = "NULL";
            //saleOrderQ.ccurrentauditor = "NULL";
            saleOrderQ.ufts = "                   141657.2265";
            saleOrderQ.id = id;
            saleOrderQ.ivtid = 131485;
            //saleOrderQ.cchanger = "NULL";
            saleOrderQ.cbustype = "普通销售";
            //saleOrderQ.ccrechpname = "NULL";
            saleOrderQ.cstcode = "01";
            //saleOrderQ.outid = "NULL";
            saleOrderQ.ddate = DateTime.Now;
            //saleOrderQ.csocode = "2025060500000200";
            saleOrderQ.ccuscode = dtoSOMain.ccuscode;
            saleOrderQ.cdepcode = "02";
            saleOrderQ.boverorder = dtoSOMain.boverorder;
            saleOrderQ.cpersoncode = "0004";
            //saleOrderQ.csccode = "NULL";
            //saleOrderQ.ccusoaddress = "NULL";
            saleOrderQ.cpaycode = "1";
            saleOrderQ.cexch_name = "人民币";
            saleOrderQ.iexchrate = 1;
            saleOrderQ.itaxrate = 13;
            saleOrderQ.imoney = dtoSOMain.imoney;
            //saleOrderQ.cmemo = "NULL";
            saleOrderQ.istatus = 1;
            saleOrderQ.cmaker = dtoSOMain.cmaker;
            //saleOrderQ.cverifier = "蔡小娟";
            //saleOrderQ.ccloser = "NULL";
            //saleOrderQ.dclosedate = "NULL";
            //saleOrderQ.dclosesystime = "NULL";
            //saleOrderQ.cdefine1 = dtoSOMain.cdefine1;
            //saleOrderQ.cdefine2 = dtoSOMain.cdefine2;
            //saleOrderQ.cdefine3 = "NULL";
            //saleOrderQ.cdefine4 = "NULL";
            //saleOrderQ.cdefine5 = "NULL";
            //saleOrderQ.cdefine6 = "NULL";
            //saleOrderQ.cdefine7 = "0";
            //saleOrderQ.cdefine8 = "NULL";
            //saleOrderQ.cdefine9 = "NULL";
            saleOrderQ.cdefine10 = dtoSOMain.cdefine10;
            //saleOrderQ.cdefine11 = "NULL";
            //saleOrderQ.cdefine12 = "NULL";
            //saleOrderQ.cdefine13 = "NULL";
            //saleOrderQ.cdefine14 = "NULL";
            //saleOrderQ.cdefine15 = "NULL";
            //saleOrderQ.cdefine16 = "NULL";
            saleOrderQ.dpredatebt = dtoSOMain.dpredatebt;
            saleOrderQ.dpremodatebt = dtoSOMain.dpremodatebt;
            //saleOrderQ.cdccode = "NULL";
            //saleOrderQ.ccccode = "01";
            saleOrderQ.ccusabbname = dtoSOMain.ccusabbname;
            saleOrderQ.cdepname = "营销部";
            saleOrderQ.cpersonname = dtoSOMain.cpersonname;
            //saleOrderQ.ccushand = "NULL";
            //saleOrderQ.ccusphone = "NULL";
            //saleOrderQ.cscname = "NULL";
            //saleOrderQ.cpayname = "n/0";
            saleOrderQ.cstname = "民品销售";
            //saleOrderQ.iarmoney = "0";
            //saleOrderQ.bdisflag = "0";
            //saleOrderQ.clocker = "NULL";
            saleOrderQ.ccusname = dtoSOMain.ccusname;
            saleOrderQ.clastcusname = dtoSOMain.clastcusname;
            //saleOrderQ.ccusaddress = "NULL";
            //saleOrderQ.breturnflag = "0";
            //saleOrderQ.icuscreline = "0";
            //saleOrderQ.ccusdefine1 = "NULL";
            //saleOrderQ.ccusdefine2 = "NULL";
            //saleOrderQ.ccusdefine3 = "NULL";
            //saleOrderQ.ccusdefine4 = "NULL";
            //saleOrderQ.ccusdefine5 = "NULL";
            //saleOrderQ.ccusdefine6 = "NULL";
            //saleOrderQ.ccusdefine7 = "NULL";
            //saleOrderQ.ccusdefine8 = "NULL";
            //saleOrderQ.ccusdefine9 = "NULL";
            //saleOrderQ.ccusdefine10 = "NULL";
            //saleOrderQ.ccusdefine11 = "NULL";
            //saleOrderQ.ccusdefine12 = "NULL";
            //saleOrderQ.ccusdefine13 = "NULL";
            //saleOrderQ.ccusdefine14 = "NULL";
            //saleOrderQ.ccusdefine15 = "NULL";
            //saleOrderQ.ccusdefine16 = "NULL";
            saleOrderQ.cauthid = dtoSOMain.cauthid;
            //saleOrderQ.ccusperson = "NULL";
            //saleOrderQ.coppcode = "NULL";
            //saleOrderQ.cmodifier = "蔡小娟";
            //saleOrderQ.dmoddate = "2025-06-05";
            //saleOrderQ.dverifydate = "2025-06-05";
            //saleOrderQ.caddcode = "NULL";
            //saleOrderQ.cdeliverunit = "NULL";
            //saleOrderQ.cpsnophone = "NULL";
            //saleOrderQ.cpsnmobilephone = "NULL";
            //saleOrderQ.ccuspersoncode = "NULL";
            //saleOrderQ.ccontactname = "NULL";
            //saleOrderQ.cmobilephone = "NULL";
            //saleOrderQ.cofficephone = "NULL";
            //saleOrderQ.iflowid = "NULL";
            //saleOrderQ.cflowname = "NULL";
            //saleOrderQ.cgatheringplan = "NULL";
            //saleOrderQ.cgatheringplanname = "NULL";
            saleOrderQ.ccreditcuscode = dtoSOMain.ccreditcuscode;
            saleOrderQ.ccreditcusname = dtoSOMain.ccreditcusname;
            //saleOrderQ.dEndDate = "NULL";
            //saleOrderQ.iverifystate = "0";
            //saleOrderQ.ireturncount = "0";
            //saleOrderQ.icreditstate = "NULL";
            //saleOrderQ.iswfcontrolled = "0";
            //saleOrderQ.bcreditdate = "0";
            saleOrderQ.dcreatesystime = DateTime.Now;
            //saleOrderQ.dverifysystime = "2025-06-05 16:41:11.160";
            //saleOrderQ.dmodifysystime = "2025-06-05 16:41:10.337";
            //saleOrderQ.ddependdate = "NULL";
            //saleOrderQ.dpinvaliddate = "NULL";
            //saleOrderQ.cchangeverifier = "NULL";
            //saleOrderQ.dchangeverifydate = "NULL";
            //saleOrderQ.dchangeverifytime = "NULL";
            //saleOrderQ.bcashsale = "0";
            //saleOrderQ.cgathingcode = "NULL";
            //saleOrderQ.iprintcount = "0";
            //saleOrderQ.bmustbook = "0";
            //saleOrderQ.fbookratio = "NULL";
            //saleOrderQ.fbooksum = "NULL";
            //saleOrderQ.fbooknatsum = "NULL";
            //saleOrderQ.fgbooksum = "NULL";
            //saleOrderQ.fgbooknatsum = "NULL";
            saleOrderQ.cinvoicecompany = dtoSOMain.cinvoicecompany;
            saleOrderQ.cinvoicecompanyabbname = dtoSOMain.cinvoicecompanyabbname;
            //saleOrderQ.contract_status = "NULL";
            //saleOrderQ.optnty_name = "NULL";
            //saleOrderQ.ioppid = "NULL";
            //saleOrderQ.csvouchtype = "NULL";
            //saleOrderQ.cgcroutecode = "NULL";
            //saleOrderQ.cgcroutename = "NULL";
            saleOrderQ.cbcode = dtoSOMain.cbcode;
            saleOrderQ.cbname = dtoSOMain.cbname;
            saleOrderQ.cbaccount = dtoSOMain.cbaccount;
            //saleOrderQ.csscode = "NULL";
            //saleOrderQ.cssname = "NULL";
            //saleOrderQ.cattachment = "NULL";
            //saleOrderQ.zdsum = "0.00";
            //saleOrderQ.linenum = "0";
            //saleOrderQ.cebtrnumber = "NULL";
            //saleOrderQ.cebbuyer = "NULL";
            //saleOrderQ.cebbuyernote = "NULL";
            //saleOrderQ.cebprovince = "NULL";
            //saleOrderQ.cebcity = "NULL";
            //saleOrderQ.cebdistrict = "NULL";
            //saleOrderQ.cinvoicecusname = "NULL";
            saleOrderQ.icustaxrate = 13;
            return SqlSugarHelp.scope.GetConnection(sugarConfigId).Insertable(saleOrderQ).AS(strHeadName).ExecuteCommand();
        }

        private static int 销售订单体赋值(string sugarConfigId,string strBodyName, int id, DtoSOMain dtoSOMain)
        {
            List<SaleOrderSQ> list = new List<SaleOrderSQ>();
            foreach (var item in dtoSOMain.saleOrderSQList)
            {
                SaleOrderSQ saleOrderSQ = new SaleOrderSQ();
                saleOrderSQ.autoid = item.autoid;
                saleOrderSQ.id = item.id;
                saleOrderSQ.cinvcode = item.cinvcode;
                //saleOrderSQ.bservice = "0";
                saleOrderSQ.cinvname = item.cinvname;
                //saleOrderSQ.cinvaddcode = "NULL";
                //saleOrderSQ.body_outid = "NULL";
                saleOrderSQ.cinvstd = item.cinvstd;
                //saleOrderSQ.cunitid = "NULL";
                saleOrderSQ.cinvm_unit = item.cinvm_unit;
                saleOrderSQ.igrouptype = item.igrouptype;
                saleOrderSQ.cgroupcode = item.cgroupcode;
                //saleOrderSQ.cinva_unit = "NULL";
                //saleOrderSQ.cinvdefine1 = "NULL";
                //saleOrderSQ.cinvdefine2 = "NULL";
                //saleOrderSQ.cinvdefine3 = "NULL";
                //saleOrderSQ.cinvdefine4 = "NULL";
                //saleOrderSQ.cinvdefine5 = "NULL";
                //saleOrderSQ.cinvdefine6 = "NULL";
                //saleOrderSQ.cinvdefine7 = "NULL";
                //saleOrderSQ.cinvdefine8 = "NULL";
                //saleOrderSQ.cinvdefine9 = "NULL";
                //saleOrderSQ.cinvdefine10 = "NULL";
                //saleOrderSQ.cinvdefine11 = "NULL";
                //saleOrderSQ.cinvdefine12 = "NULL";
                saleOrderSQ.cinvdefine13 = item.cinvdefine13;
                //saleOrderSQ.cinvdefine14 = "NULL";
                //saleOrderSQ.cinvdefine15 = "NULL";
                //saleOrderSQ.cinvdefine16 = "NULL";
                saleOrderSQ.iquantity = item.iquantity;
                //saleOrderSQ.inum = "NULL";
                saleOrderSQ.iquotedprice = item.iquotedprice;
                saleOrderSQ.iunitprice = item.iunitprice;
                //saleOrderSQ.iinvsprice = "NULL";
                //saleOrderSQ.iinvncost = "NULL";
                saleOrderSQ.funmoqty = item.funmoqty;
                saleOrderSQ.imoney = item.imoney;
                saleOrderSQ.itax = item.itax;
                saleOrderSQ.isum = item.isum;
                saleOrderSQ.inatunitprice = item.inatunitprice;
                saleOrderSQ.inatmoney = item.inatmoney;
                saleOrderSQ.inattax = item.inattax;
                saleOrderSQ.inatsum = item.inatsum;
                saleOrderSQ.inatdiscount = item.inatdiscount;
                saleOrderSQ.idiscount = item.idiscount;
                //saleOrderSQ.ifhquantity = "0.0000000000";
                //saleOrderSQ.ifhnum = "0.000000000000";
                //saleOrderSQ.ifhmoney = "0.00";
                //saleOrderSQ.ikpquantity = "0.0000000000";
                //saleOrderSQ.fsalecost = "0.0000000000";
                //saleOrderSQ.fsaleprice = "0.0000000000";
                //saleOrderSQ.iexchsum = "0.00";
                //saleOrderSQ.imoneysum = "0.00";
                //saleOrderSQ.cbsysbarcode = "||SA17|2025060500000200|1";
                //saleOrderSQ.ikpnum = "0.0000000000";
                //saleOrderSQ.ikpmoney = "0.00";
                saleOrderSQ.dpredate = item.dpredate;
                //saleOrderSQ.cmemo = "NULL";
                //saleOrderSQ.cfree1 = "NULL";
                //saleOrderSQ.cfree2 = "NULL";
                //saleOrderSQ.iinvexchrate = "NULL";
                //saleOrderSQ.iinvlscost = "NULL";
                saleOrderSQ.itaxunitprice = item.itaxunitprice;
                //saleOrderSQ.bfree1 = "0";
                //saleOrderSQ.bfree2 = "0";
                //saleOrderSQ.bfree3 = "0";
                //saleOrderSQ.bfree4 = "0";
                //saleOrderSQ.bfree5 = "0";
                //saleOrderSQ.bfree6 = "0";
                //saleOrderSQ.bfree7 = "0";
                //saleOrderSQ.bfree8 = "0";
                //saleOrderSQ.bfree9 = "0";
                //saleOrderSQ.bfree10 = "0";
                //saleOrderSQ.bsalepricefree1 = "0";
                //saleOrderSQ.bsalepricefree2 = "0";
                //saleOrderSQ.bsalepricefree3 = "0";
                //saleOrderSQ.bsalepricefree4 = "0";
                //saleOrderSQ.bsalepricefree5 = "0";
                //saleOrderSQ.bsalepricefree6 = "0";
                //saleOrderSQ.bsalepricefree7 = "0";
                //saleOrderSQ.bsalepricefree8 = "0";
                //saleOrderSQ.bsalepricefree9 = "0";
                //saleOrderSQ.bsalepricefree10 = "0";
                //saleOrderSQ.binvtype = "0";
                saleOrderSQ.itaxrate = item.itaxrate;
                //saleOrderSQ.kl = "100.0000000000";
                //saleOrderSQ.kl2 = "100.0000000000";
                //saleOrderSQ.cdefine22 = "有工艺路线";
                saleOrderSQ.cdefine23 = item.cdefine23;
                //saleOrderSQ.cdefine24 = "NULL";
                //saleOrderSQ.cdefine25 = "NULL";
                //saleOrderSQ.cdefine26 = "NULL";
                //saleOrderSQ.cdefine27 = "NULL";
                //saleOrderSQ.cdefine28 = "NULL";
                //saleOrderSQ.cdefine29 = "NULL";
                //saleOrderSQ.cdefine30 = "NULL";
                //saleOrderSQ.cdefine31 = "NULL";
                //saleOrderSQ.cdefine32 = "NULL";
                //saleOrderSQ.cdefine33 = "NULL";
                //saleOrderSQ.cdefine34 = "NULL";
                //saleOrderSQ.cdefine35 = "NULL";
                //saleOrderSQ.cdefine36 = "NULL";
                //saleOrderSQ.cdefine37 = "NULL";
                saleOrderSQ.isosid = (int)SnowFlakeSingle.Instance.NextId();
                //saleOrderSQ.citemcode = "NULL";
                //saleOrderSQ.citem_class = "NULL";
                //saleOrderSQ.dkl1 = "0.0000000000";
                //saleOrderSQ.dkl2 = "0.0000000000";
                //saleOrderSQ.citemname = "NULL";
                //saleOrderSQ.citem_cname = "NULL";
                //saleOrderSQ.cfree3 = "NULL";
                //saleOrderSQ.cfree4 = "NULL";
                //saleOrderSQ.cfree5 = "NULL";
                //saleOrderSQ.cfree6 = "NULL";
                //saleOrderSQ.cfree7 = "NULL";
                //saleOrderSQ.cfree8 = "NULL";
                //saleOrderSQ.cfree9 = "NULL";
                //saleOrderSQ.cfree10 = "NULL";
                //saleOrderSQ.cinvauthid = "NULL";
                //saleOrderSQ.cscloser = "asuser";
                saleOrderSQ.cscloser = "";
                saleOrderSQ.irowno = dtoSOMain.saleOrderSQList.IndexOf(item)+1;
                //saleOrderSQ.imoquantity = "0.000000";
                //saleOrderSQ.icusbomid = "NULL";
                saleOrderSQ.cconfigstatus = "未选配";
                saleOrderSQ.ccomunitcode = item.ccomunitcode;
                //saleOrderSQ.ippartseqid = "NULL";
                //saleOrderSQ.ippartid = "NULL";
                //saleOrderSQ.ippartqty = "NULL";
                saleOrderSQ.dpremodate = item.dpremodate;
                //saleOrderSQ.iquoid = "0";
                //saleOrderSQ.cquocode = "NULL";
                //saleOrderSQ.cbarcode = "NULL";
                //saleOrderSQ.ccontractid = "NULL";
                //saleOrderSQ.ccontracttagcode = "NULL";
                //saleOrderSQ.ccontractrowguid = "NULL";
                saleOrderSQ.batomodel = "否";
                saleOrderSQ.bptomodel = "否";
                //saleOrderSQ.ccusinvcode = "NULL";
                //saleOrderSQ.ccusinvname = "NULL";
                //saleOrderSQ.fcusminprice = "0.000000000";
                saleOrderSQ.borderbom = "否";
                //saleOrderSQ.borderbomover = "0";
                //saleOrderSQ.idemandtype = "NULL";
                //saleOrderSQ.cdemandcode = "NULL";
                //saleOrderSQ.cdemandmemo = "NULL";
                //saleOrderSQ.iprekeepquantity = "NULL";
                //saleOrderSQ.iprekeeptotquantity = "NULL";
                //saleOrderSQ.iprekeeptotnum = "NULL";
                //saleOrderSQ.busecusbom = "0";
                //saleOrderSQ.iprekeepnum = "NULL";
                saleOrderSQ.binvmodel = "否";
                //saleOrderSQ.csrpolicy = "PE";
                //saleOrderSQ.fpurquan = "0.000000";
                //saleOrderSQ.btracksalebill = "0";
                //saleOrderSQ.iadvancedate = "NULL";
                //saleOrderSQ.dreleasedate = "2025-06-07 00:00:00.000";
                //saleOrderSQ.fimquantity = "0.000000000";
                //saleOrderSQ.fomquantity = "0.000000000";
                //saleOrderSQ.bproxyforeign = "1";
                //saleOrderSQ.ballpurchase = "0";
                //saleOrderSQ.bspecialorder = "0";
                //saleOrderSQ.binvbatch = "0";
                //saleOrderSQ.btrack = "0";
                //saleOrderSQ.dedate = "NULL";
                //saleOrderSQ.bproductbill = "1";
                //saleOrderSQ.iaoids = "NULL";
                //saleOrderSQ.cpreordercode = "NULL";
                //saleOrderSQ.dbclosedate = "NULL";
                //saleOrderSQ.dbclosesystime = "NULL";
                //saleOrderSQ.bgift = "0";
                //saleOrderSQ.bsaleprice = "1";
                //saleOrderSQ.iinvid = "NULL";
                //saleOrderSQ.finquantity = "0.000000000";
                //saleOrderSQ.foutquantity = "0.000000000";
                //saleOrderSQ.fretquantity = "0.000000";
                //saleOrderSQ.fretnum = "0.000000000";
                //saleOrderSQ.iimid = "NULL";
                //saleOrderSQ.ccorvouchtype = "NULL";
                //saleOrderSQ.ccorvouchtypename = "NULL";
                //saleOrderSQ.icorrowno = "NULL";
                //saleOrderSQ.cparentcode = "NULL";
                //saleOrderSQ.cchildcode = "NULL";
                //saleOrderSQ.fchildqty = "NULL";
                //saleOrderSQ.fchildrate = "NULL";
                //saleOrderSQ.icalctype = "NULL";
                //saleOrderSQ.cordercode = "2025060500000200";
                //saleOrderSQ.bproducebyfeatureallocate = "0";
                //saleOrderSQ.icurpartid = "NULL";
                //saleOrderSQ.cfactorycode = "NULL";
                //saleOrderSQ.cfactoryname = "NULL";
                //saleOrderSQ.gcsourceid = "NULL";
                //saleOrderSQ.gcsourceids = "NULL";
                //saleOrderSQ.cdetailsdemandcode = "NULL";
                //saleOrderSQ.cdetailsdemandmemo = "NULL";
                //saleOrderSQ.cvencode = "NULL";
                //saleOrderSQ.cvenname = "NULL";
                //saleOrderSQ.cvenabbname = "NULL";
                //saleOrderSQ.cmdepcode = "NULL";
                //saleOrderSQ.cmdepname = "NULL";
                //saleOrderSQ.forecastdid = "NULL";
                //saleOrderSQ.fappqty = "NULL";
                //saleOrderSQ.fstockquan = "0.000000000";
                //saleOrderSQ.fstockquano = "0.000000000";
                //saleOrderSQ.fcanusequan = "0.000000000";
                //saleOrderSQ.fcanusequano = "0.000000000";

                list.Add(saleOrderSQ);
            }
            
            
            return SqlSugarHelp.scope.GetConnection(sugarConfigId).Insertable(list).AS(strBodyName).ExecuteCommand();
        }

      
      



       
    }
}